<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itheima" uri="http://itcast.cn/common/"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:useBean id="now" class="java.util.Date" scope="page" />
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<title>客户列表-BootCRM</title>

<!-- Bootstrap Core CSS -->
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

<!-- MetisMenu CSS -->
<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet">

<!-- DataTables CSS -->
<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet">

<!-- Custom CSS -->
<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet">

<!-- Custom Fonts -->
<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet"
	type="text/css">
<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet"
	type="text/css">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<style>
#but {
	margin: 0 auto;
}

#but1 {
	margin: 0 auto;
}

a{
font-size:18px;
}


</style>
<body>

	<div id="wrapper">

		<!-- Navigation -->
		<nav class="navbar navbar-default navbar-static-top" role="navigation"
			style="margin-bottom: 0">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target=".navbar-collapse">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="navbar-brand" href="index.html">办公自动化系统 v1.0</a>
		</div>

		
		<!-- /.navbar-header -->
    

	<ul class="nav nav-tabs navbar-left">
			<li><a href="Main">首页</a></li>
			<li>
				<li class="dropdown"  class="active"><a class="dropdown-toggle"
					data-toggle="dropdown">业务管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="Approve">业务审批</a></li>
						<li><a href="Application">业务申请</a></li>
						<li><a href="ApplicationFind">业务查看</a></li>
					</ul></li>
				<li><a href="yuangong">员工管理</a></li>
				<li><a href="organization">部门管理</a></li>
				<li class="dropdown"><a class="dropdown-toggle"
					data-toggle="dropdown">会议管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">	
						<li><a href="HuiYiAnPai">会议查看</a></li>
						<li><a href="HuiYiAnPaiSecond">会议申请记录</a></li>	
					</ul></li>
				<li><a href="Addresslist">通讯簿</a></li>
				<li><a href="GongWen">公文管理</a></li>
				
					<li class="dropdown"><a class="dropdown-toggle"
					data-toggle="dropdown">公告管理<span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="GongGao">公告查看</a></li>
						<li><a href="GongGaoNew">新建公告</a></li>
					</ul></li>
		</ul>
		
		<ul class="nav navbar-top-links navbar-right">
			<li class="dropdown">
			<a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-envelope fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
			
					

				<ul class="dropdown-menu dropdown-messages">
					<li><a href="#">
							<div>
								<strong>令狐冲</strong> <span class="pull-right text-muted">
									<em>昨天</em>
								</span>
							</div>
							<div>今天晚上向大哥找我吃饭，讨论一下去梅庄的事...</div>
					</a></li>
					<li class="divider"></li>
					<li><a class="text-center" href="#"> <strong>查看全部消息</strong>
							<i class="fa fa-angle-right"></i>
					</a></li>
				</ul> <!-- /.dropdown-messages --></li>
			<!-- /.dropdown -->
			<li class="dropdown"><a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-tasks fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
				<ul class="dropdown-menu dropdown-tasks">
					<li><a href="#">
							<div>
								<p>
									<strong>任务 1</strong> <span class="pull-right text-muted">完成40%</span>
								</p>
								<div class="progress progress-striped active">
									<div class="progress-bar progress-bar-success"
										role="progressbar" aria-valuenow="40" aria-valuemin="0"
										aria-valuemax="100" style="width: 40%">
										<span class="sr-only">完成40%</span>
									</div>
								</div>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<p>
									<strong>任务 2</strong> <span class="pull-right text-muted">完成20%</span>
								</p>
								<div class="progress progress-striped active">
									<div class="progress-bar progress-bar-info" role="progressbar"
										aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"
										style="width: 20%">
										<span class="sr-only">完成20%</span>
									</div>
								</div>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a class="text-center" href="#"> <strong>查看所有任务</strong>
							<i class="fa fa-angle-right"></i>
					</a></li>
				</ul> <!-- /.dropdown-tasks --></li>
			<!-- /.dropdown -->
			<li class="dropdown"><a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-bell fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
				<ul class="dropdown-menu dropdown-alerts">
					<li><a href="#">
							<div>
								<i class="fa fa-comment fa-fw"></i> 新回复 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<i class="fa fa-envelope fa-fw"></i> 新消息 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<i class="fa fa-tasks fa-fw"></i> 新任务 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<i class="fa fa-upload fa-fw"></i> 服务器重启 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a class="text-center" href="#"> <strong>查看所有提醒</strong>
							<i class="fa fa-angle-right"></i>
					</a></li>
				</ul> <!-- /.dropdown-alerts --></li>
			<!-- /.dropdown -->
			<li class="dropdown"><a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-user fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
				<ul class="dropdown-menu dropdown-user">
				<li><a href="#"><i class="fa fa-user fa-fw"></i> 用户设置</a></li>
					<li><a href="#"><i class="fa fa-gear fa-fw"></i> 系统设置</a></li>
					<li><a href="#"><i class="fa fa-gear fa-fw"></i>员工姓名：<%=request.getSession().getAttribute("ygname")%></a></li>
					<li><a href="#"><i class="fa fa-gear fa-fw"></i>员工工号：<%=request.getSession().getAttribute("ygid")%></a></li>
					<li><a href="#"><i class="fa fa-gear fa-fw"></i>用户名：<%=request.getSession().getAttribute("loginname")%></a></li>
					<li><a href="#"><i class="fa fa-gear fa-fw"></i>职位：<%=request.getSession().getAttribute("zhiwei")%></a> </li>
					<li><a href="#"><i class="fa fa-gear fa-fw"></i>部门：<%=request.getSession().getAttribute("organziation")%></a></li>
					<li class="divider"></li>
					<li><a href="tologin"><i class="fa fa-sign-out fa-fw"></i>
							退出登录</a></li>
				</ul> <!-- /.dropdown-user --></li>
			<!-- /.dropdown -->
		</ul>
		<!-- /.navbar-top-links -->

		<div class="navbar-default sidebar" role="navigation">
			<div class="sidebar-nav navbar-collapse">
				<ul class="nav" id="side-menu">
					<li class="sidebar-search">
						<div class="input-group custom-search-form">
							<input type="text" class="form-control" placeholder="查询内容...">
							<span class="input-group-btn">
								<button class="btn btn-default" type="button">
									<i class="fa fa-search" style="padding: 3px 0 3px 0;"></i>
								</button>
							</span>
						</div> <!-- /input-group -->
					</li>
					<li><a href="Application" class="active"><i
							class="fa fa-edit fa-fw"></i>业务申请</a></li>
					<li><a href="Approve" class="active"><i
							class="fa fa-edit fa-fw"></i>业务审批</a></li>
					<li><a href="ApplicationFind"><i
							class="fa fa-dashboard fa-fw"></i> 业务查看</a></li>
				</ul>
			</div>
			<!-- /.sidebar-collapse -->
		</div>
		<!-- /.navbar-static-side --> </nav>

	
		<div id="page-wrapper">
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">业务申请表</h1>
				</div>
			</div>
	
			<div class="row">
				<div class="col-lg-12">

					<div class="panel panel-default">
						<div class="panel-heading">
							业务申请表
							<div style="float: right">
								<a href="#" class="btn btn-success btn-xs" data-toggle="modal"
									data-target="#insertEditDialog"
									onclick="editApplicationinsert()">添加业务</a>
							</div>
						</div>

						<!-- /.panel-heading -->
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>ID</th>
									<th>申请表编号</th>
									<th>申请人</th>
									<th>工号</th>
									<th>类型</th>
									<th>详情</th>
									<th>申请时间</th>
									<th>办理时间</th>
									<th>办理状态</th>
									<th>办理部门</th>
									<th>办理人</th>
									<th>业务结果</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${page.rows}" var="row">
									<tr>
										<td width="80px">&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chcs" value="${row.id}"/>&nbsp;&nbsp;&nbsp;&nbsp;${row.id}</td>
										<td>${row.applicant_number}</td>
										<td>${row.applicant_name}</td>
										<td>${row.applicant_id}</td>
										<td>${row.applicant_type}</td>
										<td>${row.applicant_main}</td>
										<td><fmt:formatDate value="${row.applicant_time}"
												pattern="yyyy-MM-dd" /></td>
												
										<td><fmt:formatDate value="${row.approve_time}"
												pattern="yyyy-MM-dd" /></td>
										<td>${row.approve_status}</td>
										<td>${row.approve_department}</td>
										<td>${row.approve_man}</td>
										<td>${row.result}</td>
										<c:if test="${row.approve_status=='待审批'}">
										<td> 
										<a href="#" class="btn btn-primary btn-xs"   
											data-toggle="modal" data-target="#updateEditDialog"
											onclick="editApplicationupdate(${row.id})">修改</a>
										<a href="#"
											class="btn btn-danger btn-xs"
											onclick="nodelete(this)">撤回业务</a></td>
										</c:if>
										 <c:if test="${row.approve_status=='已审批'}">
										<td> 
										<a href="#" class="btn btn-primary btn-xs"
											data-toggle="modal" data-target="#updateEditDialog" 
											onclick="editApplicationupdate(${row.id})">修改</a>
										<a href="#"
											class="btn btn-danger btn-xs"
											onclick="deleteApplication(${row.id})">删除业务</a></td>
										</c:if>
									</tr>
								</c:forEach>
							</tbody>
						</table>
						<div class="col-md-12 text-right">
							<itheima:page url="${pageContext.request.contextPath }/Application" />
						</div>

					</div>

				</div>
			</div>
		</div>

	</div>



	<!-- 员工信息插入框 -->
	<div class="modal fade" id="insertEditDialog" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">新建业务项目</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="ApplicationinsertForm">
						<input type="hidden" id="id" name="id" />

						


						<div class="form-group">
							<label for="app_idinsert" class="col-sm-2 control-label">员工编号</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_idinsert"
									placeholder="员工编号" name="applicant_id" oninput="funselectYGname(this.value)">
									
							</div>
							
						</div>
					 <div class="form-group">
							<label for="app_numberinsert" class="col-sm-2 control-label">订单编号</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_numberinsert"
									placeholder="订单编号" name="applicant_number" value="<%=request.getSession().getAttribute("app_numberinsert")%>"  readonly/>
									
							</div>
							
						</div>
					
						
						
						<div class="form-group">
							<label for="app_nameinsert" class="col-sm-2 control-label">员工姓名</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_nameinsert"
									placeholder="员工姓名" name="applicant_name" readonly="readonly">
							</div>
						</div>


						<div class="form-group">
							<label for="app_typeinsert"
								style="float: left; padding: 7px 15px 0 27px;">业务类型</label>
							<div class="col-sm-10">
								<select class="form-control" id="app_typeinsert"
									placeholder="业务类型" name="applicant_type">
									<option value="">--请选择--</option>
									<c:forEach items="${typeType}" var="item">
										<option value="${item.dict_item_name}"
											<c:if test="${item.dict_id == applicant_type}"> selected</c:if>>${item.dict_item_name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="app_maininsert" class="col-sm-2 control-label">业务详情</label>
							<div class="col-sm-10">
							
								<!-- <input type="text" class="form-control" id="app_maininsert"
									placeholder="业务详情" name="applicant_main"> -->
									<textarea type="text" class="form-control"
									id="app_maininsert" name="applicant_main" placeholder="业务详情"> </textarea>
							</div>
						</div>

						<div class="form-group">
							<label for="app_timeinsert" class="col-sm-2 control-label">申请时间</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_timeinsert"
									placeholder="申请时间" name="applicant_time" value="<fmt:formatDate value='${now}' pattern="yyyy-MM-dd HH:mm:ss" />">
									
									
							</div>
						</div>
						<div class="form-group">
							<label for="app_departmentinsert"
								style="float: left; padding: 7px 15px 0 27px;">办理部门</label>
							<div class="col-sm-10">
								<select class="form-control" id="app_departmentinsert"
									name="approve_department"
									onchange="funinsert(this.options[this.options.selectedIndex].value)">
									<option value="">--请选择--</option>
									<c:forEach items="${OrganizationType}" var="item">
										<option value="${item.dict_item_name}"
											<c:if test="${item.dict_id == approve_department}"> selected</c:if>>${item.dict_item_name }</option>
									</c:forEach>
								</select>
							</div>
						</div>



						<div class="form-group">
							<label for="app_maninsert" class="col-sm-2 control-label">办理人</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_maninsert"
									placeholder="办理人" name="approve_man">
							</div>
						</div>



					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary"
						onclick="insertApplication()">保存修改</button>
				</div>
			</div>
		</div>
	</div>



<!-- 信息更新框 -->
<div class="modal fade" id="updateEditDialog" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">修改业务项目</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="ApplicationupdateForm">
						<input type="hidden" id="idupdate" name="id" />

						<div class="form-group">
							<label for="app_idupdate" class="col-sm-2 control-label">员工编号</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_idupdate"
									placeholder="员工编号" name="applicant_id"
									oninput="funselectYGname(this.value)">
							</div>
						</div>




						<div class="form-group">
							<label for="app_nameupdate" class="col-sm-2 control-label">员工姓名</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_nameupdate"
									placeholder="员工姓名" name="applicant_name" readonly="readonly">
							</div>
						</div>


						<div class="form-group">
							<label for="app_typeupdate"
								style="float: left; padding: 7px 15px 0 27px;">业务类型</label>
							<div class="col-sm-10">
								<select class="form-control" id="app_typeupdate"
									placeholder="业务类型" name="applicant_type">
									<option value="">--请选择--</option>
									<c:forEach items="${typeType}" var="item">
										<option value="${item.dict_item_name}"
											<c:if test="${item.dict_id == applicant_type}"> selected</c:if>>${item.dict_item_name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="app_mainupdate" class="col-sm-2 control-label">业务详情</label>
							<div class="col-sm-10">
							<textarea type="text" class="form-control"
									id="app_mainupdate" name="applicant_main" placeholder="业务详情"> </textarea>
								
							</div>
						</div>

						<div class="form-group">
							<label for="app_timeupdate" class="col-sm-2 control-label">申请时间</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_timeupdate"
									placeholder="申请时间" name="applicant_time" readonly="readonly">
							</div>
						</div>
						

						<div class="form-group">
							<label for="app_departmentupdate"
								style="float: left; padding: 7px 15px 0 27px;">办理部门</label>
							<div class="col-sm-10">
								<select class="form-control" id="app_departmentupdate"
									name="approve_department"
									onchange="funupdate(this.options[this.options.selectedIndex].value)">
									<option value=" ">--请选择--</option>
									<c:forEach items="${OrganizationType}" var="item">
										<option value="${item.dict_item_name}"
											<c:if test="${item.dict_id == approve_department}"> selected</c:if>>${item.dict_item_name }</option>
									</c:forEach>
								</select>
							</div>
						</div>

						<input type="hidden" id="app_statusupdate"
									 name="approve_status">

						<div class="form-group">
							<label for="app_manupdate" class="col-sm-2 control-label">办理人</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="app_manupdate"
									placeholder="办理人" name="approve_man">
							</div>
						</div>

						<div class="form-group">
							<label for="app_resultupdate"
								style="float: left; padding: 7px 15px 0 27px;">办理结果</label>
							<div class="col-sm-10">
							<input type="text" class="form-control" id="app_resultupdate"
									name="result" readonly/>
							
							
							
							</div>
						</div>



					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary"
						onclick="updateApplication()">保存修改</button>
				</div>
			</div>
		</div>
	</div>

<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
	<!-- Bootstrap Core JavaScript -->
	<script type="text/javascript" src="<%=basePath%>js/bootstrap.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/bootstrapValidator.js"></script>
	<!-- Metis Menu Plugin JavaScript -->
	<script type="text/javascript" src="<%=basePath%>js/metisMenu.min.js"></script>

	<!-- DataTables JavaScript -->
	<script type="text/javascript"
		src="<%=basePath%>js/jquery.dataTables.min.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>

	<!-- Custom Theme JavaScript -->
	<script type="text/javascript" src="<%=basePath%>js/sb-admin-2.js"></script>

	<!-- Bootstrap Core CSS -->
	<%-- <link type="text/css" href="<%=basePath%>css/bootstrap.css" rel="stylesheet"/>  --%>
	<link type="text/css"
		href="<%=basePath%>css/bootstrapValidator.min.css" rel="stylesheet" />

	<script language="JavaScript">
function editApplicationinsert() {
		$.ajax({
		type:"get",
		url:"<%=basePath%>Application/edit.action",
		data:{},
		success:function(data) {  
	
		$("#app_nameinsert").val(data.applicant_name);
		$("#app_idinsert").val(data.applicant_id);
		$("app_numberinsert".val(data.applicant_number));
		$("#app_typeinsert").val(data.applicant_type);
		
		$("#app_maininsert").val(data.applicant_main);
		
		$("#app_timeinsert").val(data.applicant_time);
		$("#app_departmentinsert").val(data.approve_department);
		$("#app_maninsert").val(data.approve_man);

	
}
});
}

function editApplicationupdate(id) {
	
	
	
	$.ajax({
	type:"get",
	url:"<%=basePath%>Application/edit.action",
	data:{"id":id},
	success:function(data) { 
		
		
		if(data.approve_status=='已审批'){
			
			alert("已审批的业务无法修改");
			window.location.reload();
		}
		
		
		
		
	$("#idupdate").val(data.id);
	$("#app_nameupdate").val(data.applicant_name);
	$("#app_idupdate").val(data.applicant_id);
	$("#app_typeupdate").val(data.applicant_type);
	$("#app_mainupdate").val(data.applicant_main);  
	$("#app_timeupdate").val(data.applicant_time);
	
	$("#app_statusupdate").val(data.approve_status);
	
	$("#approve_timeupdate").val(data.approve_time);
	$("#app_departmentupdate").val(data.approve_department);
	$("#app_manupdate").val(data.approve_man);
	$("#app_resultupdate").val(data.result);	
}
});
}

function updateApplication() {
	$.post("<%=basePath%>Application/update.action",$("#ApplicationupdateForm").serialize(),function(data){
		alert("业务修改成功！");
		window.location.reload();
	});
} 


function insertApplication() {
	$.post("<%=basePath%>Application/insert.action",$("#ApplicationinsertForm").serialize(),function(data){
		alert("新业务添加成功！");
		window.location.reload();
	});
}

function deleteApplication(id) {
	if(confirm('确实要删除该业务吗?')) {
		$.post("<%=basePath%>Application/delete.action",{"id":id},function(data){	
			if(data.statu=="yes"){
			alert("删除成功");}
			else{	
				alert("超过三个月的业务才能删除");
			}
			window.location.reload();
		});
	}
}
 



function funinsert(i){
	

	if(i==''){
		
		
	}else{
		
		$.post("<%=basePath%>Application/selectManager.action",{"approve_department":i},function(data){
			
			$("#app_maninsert").val(data);
		},"json");
	}
	
	
	
}
function funupdate(i){
	

	if(i==''){
		
		
	}else{
		
		$.post("<%=basePath%>Application/selectManager.action",{"approve_department":i},function(data){
			
			$("#app_manupdate").val(data);
		},"json");
	}
	
	
	
}
//查询员工通过输入工号
function funselectYGname(i){
	
	 $.post("<%=basePath%>Application/selectYuanGong.action",{"applicant_id":i},function(data){
		 $("#app_nameinsert").val(data);
	 },"json");
	 
}

$(function() {
	
	forminsert = $('#ApplicationinsertForm');
	
	
	checkinsert(forminsert);
	

	

});
 function nodelete(dom){
	 
	 var a=dom.parentNode.parentNode.children[11].innerText;
	
	var id=dom.parentNode.parentNode.children[0].innerText;
	id = id.replace(/\s*/g,"");
	console.log(id);
	
	debugger;
		
		if(confirm('确实要撤销该业务吗?')) {
			 if(a=='未办'){
				 var reason=prompt("请填写撤销原因","");//将输入的内容赋给变量 name
				 
				 if(reason){
				 $.post("<%=basePath%>Application/nodelete.action",{"id":id,"reason":reason},function(data){
							alert('撤销 成功');
							window.location.reload();
						
						
					},"json");}else{
						
						alert("不能为空");
					}
				 
			 }else{
				 alert("当前状态不可撤销");
				 
			 }
			}
	
		 }
	


function checkinsert(form){
	
	form.bootstrapValidator({
		excluded : 'disabled',
		message : '输入值不合法',
		feedbackIcons : {
			valid : 'glyphicon glyphicon-ok',
			invalid : 'glyphicon glyphicon-remove',
			validating : 'glyphicon glyphicon-refresh'
		},
		live : 'enabled',
		fields : {
			applicant_id : {
				validators : {
					notEmpty : {
						message : '查无此人'
					},
					stringLength : {
						min : 2,
						max : 6,
						message : '请输入2到6个字符'

					},
					regexp : {
						regexp : /^[0-9]*$/,
						message : '员工编号只能由数字组成 '
					}

				}
			},
			applicant_time : {
				validators : {
					notEmpty : {
						message : '办理时间不能为空'
					},
			regexp : {
				regexp : /^(\d{4})(-)(\d{2})(-)(\d{2})$/,
				message : '请按照YYYY-MM-dd格式输入 '
			}
		}
			}
		}
	});
	
	
	
} 



</script>

</body>

</html>
